Function: varargin2struct

CALL:

defaultOptions = varargin2struct(defaultOptions,ValidProps,... PROPERTY1,VALUE1,PROPERTY2,VALUE2,...) defaultOptions = varargin2struct(defaultOptions,ValidProps,... PROPERTY1,VALUE1,OPTSTRUCT,...)

DESCRIPTION:

Convert parameter-value combinations to structure

INPUT:

defaultOptions any
Struct with default values
ValidProps any
    Allowable fields (cell array)
PROPERTY,VALUE:
    Property-Value pairs, and/or
OPTSTRUCT:      Option structure that stores property value pairs
+----PROPERTY1=VALUE1
+----PROPERTY2=VALUE2

OUTPUT:

Options any
structure identical to defaultOptions, but appriate fields over
overwritten with property value pairs.

EXAMPLE:

   function do_some(varargin)
   defaultOptions=struct('a',1,'b',2);
   Options=varargin2struct(defaultOptions,fieldnames(defaultOptions),varargin{:});
   
    Copyright 2006-2022 Modelit, www.modelit.nl